<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <!--  <el-form-item label="报表名称" prop="rptName">
        <el-input
          v-model="queryParams.rptName"
          placeholder="请输入报表名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="记录时间" prop="rptTime">
        <el-date-picker
          :editable="false"
          clearable
          size="small"
          v-model="queryParams.rptTime"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="审核人" prop="auditor">
        <el-input
          v-model="queryParams.auditor"
          placeholder="请输入审核人"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="操作人" prop="operator">
        <UserDialog
          @dialogChange="queryParams.operator = $event.label"
          :echoValue="queryParams.operator"
          :multiple="false"
          placeholder="请选择人员"
        />
        <!-- <el-input
          v-model="queryParams.operator"
          placeholder="请输入操作人"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        /> -->
        <!--<el-select
          v-model="queryParams.operator"
          filterable
          allow-create
          placeholder="请选择操作人"
          style="width: 100%"
          @keyup.enter.native="handleQuery"
        >
          <el-option
            v-for="item in userList"
            :key="item.nickName"
            :label="item.nickName"
            :value="item.nickName"
          ></el-option>
        </el-select>
      </el-form-item>-->
      <!-- <el-form-item label="报表编码" prop="code">
        <el-input
          v-model="queryParams.code"
          placeholder="请输入报表编码"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="工厂名称" prop="factory">
        <el-input
          v-model="queryParams.factory"
          placeholder="请输入工厂名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="设备类型" prop="rptType">
        <el-select v-model="queryParams.rptType" placeholder="请选择设备类型" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select> -->
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['report_process_bulk_record:bulk_record:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['report_process_bulk_record:bulk_record:edit']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['report_process_bulk_record:bulk_record:remove']"
          >删除</el-button
        >
      </el-col>
      <!-- <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['report_process_bulk_record:bulk_record:export']"
          >导出</el-button
        >
      </el-col> -->
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-s-check"
          size="mini"
          :disabled="multiple"
          @click="handleCheck"
          v-hasPermi="['report_process_bulk_record:bulk_record:check']"
          >审核</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="bulk_recordList"
      @selection-change="handleSelectionChange"
      max-height="500"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="编号" align="center" prop="id" width="80px" />
      <!--  <el-table-column label="报表名称" align="center" prop="rptName" /> -->
      <el-table-column
        label="记录时间"
        align="center"
        prop="rptTime"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.rptTime, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column label="报表编码" align="center" prop="code" min-width="150px"/>
      <el-table-column label="工厂名称" align="center" prop="factory" min-width="150px"/>
      <el-table-column label="设备类型" align="center" prop="rptType" />

      <el-table-column label="操作人" align="center" prop="operator" />
      <el-table-column label="审核人" align="center" prop="auditor" />
      <!-- <el-table-column label="备注" align="center" prop="remark" /> -->
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
        min-width="250px"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="excelhandleView(scope.row)"
          >导出</el-button            >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['report_process_bulk_record:bulk_record:edit']"
          >修改</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="handleView(scope.row)"
            >查看</el-button
          >

          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['report_process_bulk_record:bulk_record:remove']"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改灌装机操作记录对话框 -->
    <el-dialog
    fullscreen
      :title="title"
      :visible.sync="open"
      width="700px"
      append-to-body
      custom-class="myDialog"
    >
      <TableHeader
        @nameChange="nameChange"
        @nameChange2="nameChange2"
        :data="{
          mainTitle: '灌装机操作记录',
          company: form.factory,
          code: form.code,
        }"
      />
      <el-form ref="form" :model="form" :rules="rules" label-width="90px">
        <el-row>
          <!-- <el-col :span="12">
                <el-form-item label="报表名称" prop="rptName">
                  <el-input v-model="form.rptName" placeholder="请输入报表名称" :disabled="openDisabled" />
                </el-form-item>
            </el-col> -->
          <el-col :span="12">
            <el-form-item label="记录时间" prop="rptTime">
              <el-date-picker
                :editable="false"
                clearable
                size="small"
                v-model="form.rptTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择记录时间"
                :disabled="openDisabled"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>

          <!-- <el-col :span="12">
                <el-form-item label="报表编码" prop="code">
                  <el-input v-model="form.code" placeholder="请输入报表编码" :disabled="openDisabled" />
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item label="工厂名称" prop="factory">
                  <el-input v-model="form.factory" placeholder="请输入工厂名称" :disabled="openDisabled" />
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item label="设备类型" prop="rptType">
                  <el-select v-model="form.rptType" placeholder="请选择设备类型" :disabled="openDisabled">
                    <el-option label="请选择字典生成" value="" />
                  </el-select>
                </el-form-item>
            </el-col> -->
        </el-row>
        <!-- 灌装机操作记录信息 -->
        <br />
        <el-divider content-position="center">灌装机操作记录信息</el-divider>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              icon="el-icon-plus"
              size="mini"
              @click="handleAddRptProBulking"
              :disabled="openDisabled"
              >添加</el-button
            >
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="danger"
              icon="el-icon-delete"
              size="mini"
              @click="handleDeleteRptProBulking"
              :disabled="openDisabled"
              >删除</el-button
            >
          </el-col>
        </el-row>
        <el-divider content-position="center"></el-divider>
        <el-table
          :data="rptProBulkingList"
          :row-class-name="rowRptProBulkingIndex"
          @selection-change="handleRptProBulkingSelectionChange"
          ref="rptProBulking"
        >
          <el-table-column type="selection" width="50" align="center" fixed />
          <!-- <el-table-column label="序号" align="center" prop="index" width="50"/> -->
          <el-table-column label="产品名称" prop="gg" fixed minWidth="300">
            <template slot-scope="scope">
              <!-- <el-select
                v-model="scope.row.productName"
                placeholder="请选择产品名称"
                style="width: 100%"
              >
                <el-option
                  v-for="dict in report_bulking_cpmc"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictLabel"
                ></el-option>
              </el-select> -->
              <Dialog
                @dialogChange="dialogChange($event, scope)"
                :echoValue="scope.row.ggname"
                parameter="rows"
                value="id"
                label="name"
                :multiple="false"
                search="name/code"
                url="/basic/productInfo/listSelect"
                :column="['产成品编号/code', '产成品名称/name']"
                placeholder="请选择内容"
                :axiosData="{typeCode: 'YYTRKQS'}"
                :openDisabled="openDisabled"
              />
            </template>
          </el-table-column>
          <el-table-column label="开机时间" prop="startTime" minWidth="110">
            <template slot-scope="scope">
              <el-time-picker
                :editable="false"
                clearable
                v-model="scope.row.startTime"
                type="time"
                value-format="HH:mm"
                format="HH:mm"
                placeholder="选择时间"
                :disabled="openDisabled"
              >
              </el-time-picker>
            </template>
          </el-table-column>
          <el-table-column label="停机时间" prop="stopTime" minWidth="110">
            <template slot-scope="scope">
              <el-time-picker
                :editable="false"
                clearable
                v-model="scope.row.stopTime"
                type="time"
                value-format="HH:mm"
                format="HH:mm"
                placeholder="选择时间"
                :disabled="openDisabled"
              >
              </el-time-picker>
            </template>
          </el-table-column>
          <el-table-column label="PET瓶坯损耗数量" prop="petNum">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.petNum"
                placeholder="请输入PET瓶坯损耗数量"
                :disabled="openDisabled"
                type="number"
              />
            </template>
          </el-table-column>
          <el-table-column label="瓶盖损耗数量" prop="capNum">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.capNum"
                placeholder="请输入瓶盖损耗数量"
                :disabled="openDisabled"
                type="number"
              />
            </template>
          </el-table-column>
          <!-- <el-table-column label="备注" prop="remark">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.remark"
                type="textarea"
                placeholder="请输入内容"
                :disabled="openDisabled"
              />
            </template>
          </el-table-column> -->
        </el-table>
        <!-- Day灌装机操作日报信息 -->
        <br />
        <el-divider content-position="center">灌装机操作日报信息</el-divider>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              icon="el-icon-plus"
              size="mini"
              @click="handleAddRptProBulkingDay"
              :disabled="openDisabled"
              >添加</el-button
            >
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="danger"
              icon="el-icon-delete"
              size="mini"
              @click="handleDeleteRptProBulkingDay"
              :disabled="openDisabled"
              >删除</el-button
            >
          </el-col>
        </el-row>
        <el-divider content-position="center"></el-divider>
        <el-table
          :data="rptProBulkingDayList"
          :row-class-name="rowRptProBulkingDayIndex"
          @selection-change="handleRptProBulkingDaySelectionChange"
          ref="rptProBulkingDay"
        >
          <el-table-column type="selection" width="50" align="center" />
          <el-table-column
            label="序号"
            align="center"
            prop="index"
            width="50"
          />
          <el-table-column label="空调运行情况" prop="airStatus" minWidth="160">
            <template slot-scope="scope">
              <el-radio-group
                v-model="scope.row.airStatus"
                :disabled="openDisabled"
              >
                <el-radio
                  v-for="dict in report_bulking_ktyx"
                  :key="dict.index"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                ></el-radio>
              </el-radio-group>
            </template>
          </el-table-column>
          <!-- <el-table-column label="异常说明" prop="abnormal">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.abnormal"
                placeholder="请输入异常说明"
                :disabled="openDisabled"
              />
            </template>
          </el-table-column> -->
          <el-table-column label="杀菌系统开启时间" prop="startTime">
            <template slot-scope="scope">
              <el-time-picker
                :editable="false"
                clearable
                size="small"
                v-model="scope.row.startTime"
                type="time"
                value-format="HH:mm"
                format="HH:mm"
                placeholder="选择杀菌系统开启时间"
                :disabled="openDisabled"
              >
              </el-time-picker>
            </template>
          </el-table-column>
          <!-- <el-table-column label="PET瓶坯损耗数量" prop="sterilizeStatus">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.sterilizeStatus"
                placeholder="请输入PET瓶坯损耗数量"
                :disabled="openDisabled"
              />
            </template>
          </el-table-column> -->
          <el-table-column label="杀菌异常情况" prop="sterilizeAbnormal">
            <template slot-scope="scope">
              <!-- <el-input
                v-model="scope.row.sterilizeAbnormal"
                placeholder="请输入杀菌异常情况"
                :disabled="openDisabled"
              /> -->
              <el-select
                v-model="scope.row.sterilizeAbnormal"
                :disabled="openDisabled"
              >
                <el-option value="正常">正常</el-option>
                <el-option value="异常">异常</el-option>
              </el-select>
            </template>
          </el-table-column>
          <!-- <el-table-column label="备注" prop="remark">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.remark"
                type="textarea"
                placeholder="请输入内容"
                :disabled="openDisabled"
              />
            </template>
          </el-table-column> -->
        </el-table>

        <!-- Check 灌装机自检信息-->
        <br />
        <el-divider content-position="center">灌装机自检信息</el-divider>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              icon="el-icon-plus"
              size="mini"
              @click="handleAddRptProBulkingCheck"
              :disabled="openDisabled"
              >添加</el-button
            >
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="danger"
              icon="el-icon-delete"
              size="mini"
              @click="handleDeleteRptProBulkingCheck"
              :disabled="openDisabled"
              >删除</el-button
            >
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="danger"
              icon="el-icon-delete"
              size="mini"
              @click="duplication1"
              :disabled="openDisabled"
              >复制</el-button
            >
          </el-col>
        </el-row>
        <el-divider content-position="center"></el-divider>
        <el-table
          :data="rptProBulkingCheckList"
          :row-class-name="rowRptProBulkingCheckIndex"
          @selection-change="handleRptProBulkingCheckSelectionChange"
          ref="rptProBulkingCheck"
        >
          <el-table-column type="selection" width="50" align="center" />
          <!-- <el-table-column
            label="序号"
            align="center"
            prop="index"
            width="50"
          /> -->
          <el-table-column label="记录时间" prop="recordTime" minWidth="150px">
            <template slot-scope="scope">
              <el-time-picker
                :editable="false"
                clearable
                v-model="scope.row.recordTime"
                value-format="HH:mm"
                format="HH:mm"
                placeholder="选择记录时间"
                :disabled="openDisabled"
              >
              </el-time-picker>
            </template>
          </el-table-column>
          <el-table-column label="灌装容量" prop="gzrl" minWidth="150px">
            <template slot-scope="scope">
              <!-- <el-input
                v-model="scope.row.gzrl"
                placeholder="请输入灌装容量"
                :disabled="openDisabled"
              /> -->
              <el-select v-model="scope.row.gzrl" :disabled="openDisabled">
                <el-option value="正常">正常</el-option>
                <el-option value="异常">异常</el-option>
              </el-select>
            </template>
          </el-table-column>
          <el-table-column label="压盖" prop="yg" minWidth="130px">
            <template slot-scope="scope">
              <!-- <el-input
                v-model="scope.row.yg"
                placeholder="请输入压盖"
                :disabled="openDisabled"
              /> -->
              <el-select v-model="scope.row.yg" :disabled="openDisabled">
                <el-option value="正常">正常</el-option>
                <el-option value="异常">异常</el-option>
              </el-select>
            </template>
          </el-table-column>
          <el-table-column label="压盖" prop="water" minWidth="130px">
            <template slot-scope="scope">
              <el-select v-model="scope.row.water" :disabled="openDisabled">
                <el-option value="合格">合格</el-option>
                <el-option value="不合格">不合格</el-option>
              </el-select>
            </template>
          </el-table-column>
          <el-table-column
            label="真空泵运行情况"
            prop="zkbyxqk"
            minWidth="200px"
          >
            <template slot-scope="scope">
              <!-- <el-input
                v-model="scope.row.zkbyxqk"
                placeholder="请输入真空泵运行情况"
                :disabled="openDisabled"
              /> -->

              <el-select v-model="scope.row.zkbyxqk" :disabled="openDisabled">
                <el-option value="正常">正常</el-option>
                <el-option value="异常">异常</el-option>
              </el-select>
            </template>
          </el-table-column>
          <el-table-column
            :label="'冲盖终端过滤器压力(Mpa)'"
            prop="cgzdyl"
            minWidth="230px"
          >
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.cgzdyl"
                placeholder="请输入冲盖终端过滤器压力"
                :disabled="openDisabled"
                type="number"
              />
            </template>
          </el-table-column>
          <el-table-column
            :label="'灌装终端过滤器压力(Mpa)'"
            prop="gzzdyl"
            minWidth="250px"
          >
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.gzzdyl"
                placeholder="请输入灌装终端过滤器压力"
                :disabled="openDisabled"
                type="number"
              />
            </template>
          </el-table-column>
          <el-table-column
            :label="'真空泵压力(Mpa)'"
            prop="zkbyl"
            minWidth="200px"
          >
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.zkbyl"
                placeholder="请输入真空泵压力"
                :disabled="openDisabled"
                type="number"
              />
            </template>
          </el-table-column>
          <el-table-column
            :label="'一道冲盖水压力(Mpa)'"
            prop="ydcgsyl"
            minWidth="200px"
          >
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.ydcgsyl"
                placeholder="请输入一道冲盖水压力"
                :disabled="openDisabled"
                type="number"
              />
            </template>
          </el-table-column>
          <el-table-column
            :label="'二道冲盖水压力(Mpa)'"
            prop="edcgsyl"
            minWidth="200px"
          >
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.edcgsyl"
                placeholder="请输入二道冲盖水压力"
                :disabled="openDisabled"
                type="number"
              />
            </template>
          </el-table-column>
          <el-table-column label="温度（℃）" prop="wd" minWidth="120px">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.wd"
                placeholder="请输入温度"
                :disabled="openDisabled"
                type="number"
              />
            </template>
          </el-table-column>
          <el-table-column label="湿度（%）" prop="sd" minWidth="120px">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.sd"
                placeholder="请输入湿度"
                :disabled="openDisabled"
                type="number"
              />
            </template>
          </el-table-column>
          <el-table-column label="操作" width="100">
            <template slot-scope="scope">
              <el-button
                type="primary"
                plain
                icon="el-icon-search"
                @click="handleDate(scope)"
                :disabled="openDisabled"
                >读取数据</el-button
              >
            </template>
          </el-table-column>
          <!-- <el-table-column label="备注" prop="remark">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.remark"
                type="textarea"
                placeholder="请输入内容"
                :disabled="openDisabled"
              />
            </template>
          </el-table-column> -->
        </el-table>

        <!-- Seri 灌装机消毒记录信息-->
        <br />
        <el-divider content-position="center">灌装机消毒记录信息</el-divider>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              icon="el-icon-plus"
              size="mini"
              @click="handleAddRptProBulkingSterilize"
              :disabled="openDisabled"
              >添加</el-button
            >
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="danger"
              icon="el-icon-delete"
              size="mini"
              @click="handleDeleteRptProBulkingSterilize"
              :disabled="openDisabled"
              >删除</el-button
            >
          </el-col>
        </el-row>
        <el-divider content-position="center"></el-divider>
        <el-table
          :data="rptProBulkingSterilizeList"
          :row-class-name="rowRptProBulkingSterilizeIndex"
          @selection-change="handleRptProBulkingSterilizeSelectionChange"
          ref="rptProBulkingSterilize"
        >
          <el-table-column type="selection" width="50" align="center" />
          <!-- <el-table-column
            label="序号"
            align="center"
            prop="index"
            width="50"
          /> -->
          <el-table-column label="班前管路杀菌" >
             <el-table-column label="工艺要求：CIP灌装5min，每个阀排水60s" prop="bqglsj">
            <template slot-scope="scope">
              <!-- <el-input
                v-model="scope.row.bqglsj"
                placeholder="请输入班前管路杀菌"
                :disabled="openDisabled"
              /> -->
              <el-select v-model="scope.row.bqglsj" :disabled="openDisabled">
                <el-option value="已完成">已完成</el-option>
                <el-option value="未完成">未完成</el-option>
              </el-select>
            </template>
             </el-table-column>
          </el-table-column>
          <el-table-column label="班前班后机器杀菌">
           <el-table-column label="工艺要求：喷洒浓度为100mg/L的次氯酸钠" prop="bqbhjqsj">
            <template slot-scope="scope">
              <!-- <el-input
                v-model="scope.row.bqbhjqsj"
                placeholder="请输入班前班后机器杀菌"
                :disabled="openDisabled"
              /> -->
              <el-select v-model="scope.row.bqbhjqsj" :disabled="openDisabled">
                <el-option value="已完成">已完成</el-option>
                <el-option value="未完成">未完成</el-option>
              </el-select>
            </template>
             </el-table-column>
          </el-table-column>
          <!--  <el-table-column label="记录时间说" prop="recordTime">
            <template slot-scope="scope">
              <el-date-picker
                clearable
                size="small"
                v-model="scope.row.recordTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择记录时间说"
                :disabled="openDisabled"
              >
              </el-date-picker>
            </template>
          </el-table-column> -->
          <el-table-column label="班后冲盖水系统杀菌">
             <el-table-column label="工艺要求：浓度为10±2mg/L的次氯酸钠循环10min" prop="bhcgsxtsj">
            <template slot-scope="scope">
              <!--  <el-input
                v-model="scope.row.bhcgsxtsj"
                placeholder="请输入班后冲盖水系统杀菌"
                :disabled="openDisabled"
              /> -->
              <el-select v-model="scope.row.bhcgsxtsj" :disabled="openDisabled">
                <el-option value="已完成">已完成</el-option>
                <el-option value="未完成">未完成</el-option>
              </el-select>
            </template>
             </el-table-column>
          </el-table-column>
          <el-table-column label="班后管路杀菌" >
             <el-table-column label="工艺要求：CIP灌装缸2min，灌装阀3min" prop="bhglsj">
            <template slot-scope="scope">
              <!-- <el-input
                v-model="scope.row.bhglsj"
                placeholder="请输入班后管路杀菌"
                :disabled="openDisabled"
              /> -->
              <el-select v-model="scope.row.bhglsj" :disabled="openDisabled">
                <el-option value="已完成">已完成</el-option>
                <el-option value="未完成">未完成</el-option>
              </el-select>
            </template>
             </el-table-column>
          </el-table-column>
          <!-- <el-table-column label="备注" prop="remark">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.remark"
                type="textarea"
                placeholder="请输入内容"
                :disabled="openDisabled"
              />
            </template>
          </el-table-column> -->
        </el-table>

        <!-- 审核 -->
        <el-col :span="24">
          <el-form-item label="备注" prop="remark">
            <el-input
              v-model="form.remark"
              type="textarea"
              placeholder="请输入内容"
              :disabled="openDisabled"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="审核人" prop="auditor">
            <el-input
              v-model="form.auditor"

              :disabled="true"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="操作人" prop="operator">
            <UserDialog
              @dialogChange="form.operator = $event.label"
              :echoValue="form.operator"
              :multiple="false"
              :openDisabled="openDisabled"
              placeholder="请选择人员"
            />
            <!-- <el-input
              v-model="form.operator"
              placeholder="请输入操作人"
              :disabled="openDisabled"
            /> -->
           <!-- <el-select
              v-model="form.operator"
              filterable
              allow-create
              placeholder="请选择操作人"
              style="width: 100%"
              :disabled="openDisabled"
            >
              <el-option
                v-for="item in userList"
                :key="item.nickName"
                :label="item.nickName"
                :value="item.nickName"
              ></el-option>
            </el-select>-->
          </el-form-item>
        </el-col>
      </el-form>
      <div slot="footer" class="dialog-footer" v-if="!openDisabled">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listBulk_record,
  getBulk_record,
  delBulk_record,
  addBulk_record,
  updateBulk_record,
  checkBulk_record,
  handleDate,
} from "@/api/report/process/bulk_record";
import { getInfo } from "@/api/login";
import { listUser } from "@/api/system/user";

export default {
  name: "Bulk_record",
  data() {
    return {
      /* 当前用户名 */
      nickName: "",
      userList: [],
      //弹窗是否禁止编辑
      openDisabled: true,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 子表选中数据
      checkedRptProBulking: [],
      // 子表选中数据
      checkedRptProBulkingSterilize: [],
      // 子表选中数据
      checkedRptProBulkingDay: [],
      // 子表选中数据
      checkedRptProBulkingCheck: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 生产过程记录表格数据
      bulk_recordList: [],
      // 灌装机操作记录表格数据
      rptProBulkingList: [],
      rptProBulkingSterilizeList: [],
      // 灌装机操作日报表格数据
      rptProBulkingDayList: [],
      // 灌装机自检表格数据
      rptProBulkingCheckList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 50,
        rptName: null,
        rptTime: null,
        rptTime1: null,
        auditor: null,
        operator: null,
        code: null,
        factory: null,
        rptType: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
    };
  },
  created() {
    this.getList();
    this.queryUserList();
    this.getDicts("report_bulking_cpmc").then((response) => {
      this.report_bulking_cpmc = response.data;
    });
    this.getDicts("report_bulking_ktyx").then((response) => {
      this.report_bulking_ktyx = response.data;
    });
  },
  methods: {
    // 复制最后一行
    duplication1(){
      let arr = this.rptProBulkingCheckList;
      let obj = arr[arr.length - 1];
      var obj1 = JSON.parse(JSON.stringify(obj));
      this.rptProBulkingCheckList.push(obj1);
    },
    // 读取数据
    handleDate(scope) {
      // console.log(scope);
      if (this.form.rptTime == "" || this.form.rptTime == null) {
        this.msgError("请输入记录日期");
      } else {
        const time = scope.row.recordTime;
        const data = this.form.rptTime + " " + time;

        if (time == "" || time == null) {
          this.msgError("请输入记录时间");
        } else {
          // 调取接口
          handleDate({
            startTime: data + ":00"
          }).then((res) => {
            this.rptProBulkingCheckList[scope.$index].wd =
              res.data.wd;
            this.rptProBulkingCheckList[scope.$index].sd = res.data.sd;
          });
        }
      }
    },
    dialogChange(event, scope) {
      this.rptProBulkingList[scope.$index].gg = event.options.code;
      this.rptProBulkingList[scope.$index].ggname = event.label;
    },
    /** 查询生产过程记录列表 */
    getList() {
      this.loading = true;
      listBulk_record(this.queryParams).then((response) => {
        this.bulk_recordList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        rptName: null,
        rptTime: null,
        auditor: null,
        operator: this.nickName,
        code: "LS-QF-LS1-07-09-01",
        factory: "青岛崂山矿泉水有限公司",
        rptType: "灌装机",
        delFlag: null,
        remark: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
      };
      this.rptProBulkingList = [];
      this.rptProBulkingSterilizeList = [];
      this.rptProBulkingDayList = [];
      this.rptProBulkingCheckList = [];
      this.resetForm("form");

      const myDate = new Date();
      const year = myDate.getFullYear();
      const month = myDate.getMonth() + 1;
      const day = myDate.getDate();
      this.form.rptTime = `${year}-${month}-${day}`;
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;

      if (this.queryParams.rptTime != null) {
        let arr = this.queryParams.rptTime;
        this.queryParams.rptTime = arr[0];
        this.queryParams.rptTime1 = arr[1];
      }
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.openDisabled = false;
      this.open = true;
      this.title = "添加生产过程记录";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      this.openDisabled = false;
      const id = row.id || this.ids;
      getBulk_record(id).then((response) => {
        this.form = response.data;
        this.rptProBulkingList = response.data.rptProBulkingList;

        this.rptProBulkingCheckList = response.data.rptProBulkingCheckList;
        this.rptProBulkingDayList = response.data.rptProBulkingDayList;
        this.rptProBulkingSterilizeList =
          response.data.rptProBulkingSterilizeList;

        this.open = true;
        this.title = "修改生产过程记录";
      });
    },
    /** 查看按钮 */
    handleView(row) {
      this.reset();
      this.openDisabled = true;
      const id = row.id || this.ids;
      getBulk_record(id).then((response) => {
        console.log(response.data);
        this.form = response.data;
        this.rptProBulkingList = response.data.rptProBulkingList;

        this.rptProBulkingCheckList = response.data.rptProBulkingCheckList;
        this.rptProBulkingDayList = response.data.rptProBulkingDayList;
        this.rptProBulkingSterilizeList =
          response.data.rptProBulkingSterilizeList;

        this.open = true;
        this.title = "查看生产过程记录";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          this.form.rptProBulkingList = this.rptProBulkingList;

          this.form.rptProBulkingCheckList = this.rptProBulkingCheckList;
          this.form.rptProBulkingDayList = this.rptProBulkingDayList;
          this.form.rptProBulkingSterilizeList =
            this.rptProBulkingSterilizeList;
            /**打开遮罩层*/
            const rLoading = this.openLoading();
          if (this.form.id != null) {
            updateBulk_record(this.form)
              .then((response) => {
                /**成功后执行关闭遮罩层*/
                rLoading.close();
                this.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              })
              .catch((error) => {
                /**请求异常后执行关闭遮罩层*/
                rLoading.close();
              });
          } else {
            addBulk_record(this.form)
              .then((response) => {
                /**成功后执行关闭遮罩层*/
                rLoading.close();
                this.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              })
              .catch((error) => {
                /**请求异常后执行关闭遮罩层*/
                rLoading.close();
              });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm(
        '是否确认删除生产过程记录编号为"' + ids + '"的数据项?',
        "警告",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(function () {
          return delBulk_record(ids);
        })
        .then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 灌装机操作记录序号 */
    rowRptProBulkingIndex({ row, rowIndex }) {
      row.index = rowIndex + 1;
    },
    /** 灌装机操作记录添加按钮操作 */
    handleAddRptProBulking() {
      let obj = {};
      obj.gg = "";
      obj.ggname = "";
      obj.startTime = "";
      obj.stopTime = "";
      obj.petNum = "";
      obj.capNum = "";
      obj.remark = "";
      this.rptProBulkingList.push(obj);
    },
    /** 灌装机操作记录删除按钮操作 */
    handleDeleteRptProBulking() {
      if (this.checkedRptProBulking.length == 0) {
        this.$alert("请先选择要删除的灌装机操作记录数据", "提示", {
          confirmButtonText: "确定",
        });
      } else {
        this.rptProBulkingList.splice(
          this.checkedRptProBulking[0].index - 1,
          1
        );
      }
    },
    /** 单选框选中数据 */
    handleRptProBulkingSelectionChange(selection) {
      if (selection.length > 1) {
        this.$refs.rptProBulking.clearSelection();
        this.$refs.rptProBulking.toggleRowSelection(selection.pop());
      } else {
        this.checkedRptProBulking = selection;
      }
    },

    excelhandleView(row){
      this.download(
        "Laboratory/bulk_record/exportexcel?id="+row.id,
        {
          ...this.queryParams,
        },
        "灌装机操作记录" + this.parseTime(new Date()) + ".xlsx"
      );
    },

    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "report/bulk_record/export",
        {
          ...this.queryParams,
        },
        "生产过程记录" + this.parseTime(new Date()) + ".xlsx"
      );
    },
    /** 灌装机消毒记录序号 */
    rowRptProBulkingSterilizeIndex({ row, rowIndex }) {
      row.index = rowIndex + 1;
    },
    /** 灌装机消毒记录添加按钮操作 */
    handleAddRptProBulkingSterilize() {
      let obj = {};
      obj.bqglsj = "已完成";
      obj.bqbhjqsj = "已完成";
      obj.recordTime = "";
      obj.bhcgsxtsj = "已完成";
      obj.bhglsj = "已完成";
      obj.remark = "";
      this.rptProBulkingSterilizeList.push(obj);
    },
    /** 灌装机消毒记录删除按钮操作 */
    handleDeleteRptProBulkingSterilize() {
      if (this.checkedRptProBulkingSterilize.length == 0) {
        this.$alert("请先选择要删除的灌装机消毒记录数据", "提示", {
          confirmButtonText: "确定",
        });
      } else {
        this.rptProBulkingSterilizeList.splice(
          this.checkedRptProBulkingSterilize[0].index - 1,
          1
        );
      }
    },
    /** 单选框选中数据 */
    handleRptProBulkingSterilizeSelectionChange(selection) {
      if (selection.length > 1) {
        this.$refs.rptProBulkingSterilize.clearSelection();
        this.$refs.rptProBulkingSterilize.toggleRowSelection(selection.pop());
      } else {
        this.checkedRptProBulkingSterilize = selection;
      }
    },
    /** 灌装机操作日报序号 */
    rowRptProBulkingDayIndex({ row, rowIndex }) {
      row.index = rowIndex + 1;
    },
    /** 灌装机操作日报添加按钮操作 */
    handleAddRptProBulkingDay() {
      let obj = {};
      obj.airStatus = "";
      obj.abnormal = "";
      obj.startTime = "";
      obj.sterilizeStatus = "";
      obj.sterilizeAbnormal = "";
      obj.remark = "";
      this.rptProBulkingDayList.push(obj);
    },
    /** 灌装机操作日报删除按钮操作 */
    handleDeleteRptProBulkingDay() {
      if (this.checkedRptProBulkingDay.length == 0) {
        this.$alert("请先选择要删除的灌装机操作日报数据", "提示", {
          confirmButtonText: "确定",
        });
      } else {
        this.rptProBulkingDayList.splice(
          this.checkedRptProBulkingDay[0].index - 1,
          1
        );
      }
    },
    /** 单选框选中数据 */
    handleRptProBulkingDaySelectionChange(selection) {
      if (selection.length > 1) {
        this.$refs.rptProBulkingDay.clearSelection();
        this.$refs.rptProBulkingDay.toggleRowSelection(selection.pop());
      } else {
        this.checkedRptProBulkingDay = selection;
      }
    },
    /** 灌装机自检序号 */
    rowRptProBulkingCheckIndex({ row, rowIndex }) {
      row.index = rowIndex + 1;
    },
    /** 灌装机自检添加按钮操作 */
    handleAddRptProBulkingCheck() {
      let obj = {};
      obj.recordTime = "";
      obj.gzrl = "正常";
      obj.yg = "正常";
      obj.water = "合格";
      obj.zkbyxqk = "正常";
      obj.cgzdyl = "";
      obj.gzzdyl = "";
      obj.zkbyl = "";
      obj.ydcgsyl = "";
      obj.edcgsyl = "";
      obj.wd = "";
      obj.sd = "";
      obj.remark = "";
      this.rptProBulkingCheckList.push(obj);
    },
    /** 灌装机自检删除按钮操作 */
    handleDeleteRptProBulkingCheck() {
      if (this.checkedRptProBulkingCheck.length == 0) {
        this.$alert("请先选择要删除的灌装机自检数据", "提示", {
          confirmButtonText: "确定",
        });
      } else {
        this.rptProBulkingCheckList.splice(
          this.checkedRptProBulkingCheck[0].index - 1,
          1
        );
      }
    },
    /** 单选框选中数据 */
    handleRptProBulkingCheckSelectionChange(selection) {
      if (selection.length > 1) {
        this.$refs.rptProBulkingCheck.clearSelection();
        this.$refs.rptProBulkingCheck.toggleRowSelection(selection.pop());
      } else {
        this.checkedRptProBulkingCheck = selection;
      }
    },
    //接收编号
    nameChange(e) {
      this.form.code = e;
    },
    nameChange2(e) {
      this.form.factory = e;
    },
    /** 审核按钮操作 */
    handleCheck(row) {
      /* 审核 */
      this.ids.forEach((id) => {
        getBulk_record(id).then((response) => {
          if (response.data.auditor != null && response.data.auditor != "") {
            this.msgError(
              '编号为"' + id + '"的数据项已审核完成，无需重复审核！'
            );
          } else {
            let obj = {};
            obj.id = id;
            obj.auditor = this.nickName;
            obj.rptProBulkingList = this.rptProBulkingList;
            obj.rptProBulkingSterilizeList = this.rptProBulkingSterilizeList;
            obj.rptProBulkingDayList = this.rptProBulkingDayList;
            obj.rptProBulkingCheckList = this.rptProBulkingCheckList;
            /* 修改 */
            checkBulk_record(obj).then((response) => {
              this.msgSuccess("审核成功");
              this.getList();
            });
          }
        });
      });
    },
    /* 查询用户列表 */
    queryUserList() {
      listUser().then((response) => {
        this.userList = response.rows;
      });
      getInfo().then((response) => {
        this.nickName = response.user.nickName;
      });
    },
  },
};
</script>
<style>
.el-table .cell {
  white-space: pre-line;
}
</style>
